﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <title>字典列表</title>
    <meta name="viewport" content="width=device-width" />
    <link href="~/Content/layui/css/layui.css" rel="stylesheet" />
    <link href="~/Content/framework/css/console.css" rel="stylesheet" />
    <link href="~/Content/framework/css/animate.css" rel="stylesheet" />
    <link href="~/Content/font-awesome/css/font-awesome.min.css" rel="stylesheet" />
    <!--[if lt IE 9]>
        <script src="/Content/jquery/jquery-1.9.1.min.js"></script>
    <![endif]-->
    <!--[if gte IE 9]><!-->
    <script src="~/Content/jquery/jquery.min.js"></script>
    <!--<![endif]-->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <script src="~/Content/layui/layui.js"></script>
    <script src="~/Content/framework/js/global.js"></script>
</head>
<body>
    <div class="panel animated fadeIn">
        <div class="panel-body">
            <div style="margin: 15px">
                <div id="toolbar" class="elight-table-toolbar">
                    <div class="layui-btn-group">
                        <button id="item-add" onclick="btn_print()" class="layui-btn layui-btn-primary layui-btn-small">
                            <i class="fa fa-plus-square-o" aria-hidden="true"></i>打印测试
                        </button>
                        <button id="item-view" onclick="btn_print_view()" class="layui-btn layui-btn-primary layui-btn-small">
                            <i class="fa fa-plus-square-o" aria-hidden="true"></i>预览
                        </button>
                        <button id="item-export" onclick="btn_export()" class="layui-btn layui-btn-primary layui-btn-small">
                            <i class="fa fa-plus-square-o" aria-hidden="true"></i>导出PDF
                        </button>
                        <button id="item-export" onclick="btn_exportExcel()" class="layui-btn layui-btn-primary layui-btn-small">
                            <i class="fa fa-plus-square-o" aria-hidden="true"></i>表格数据导出Excel
                        </button>
                    </div>
                    <button id="btnSearch" class="toolbar-search-button layui-btn layui-btn-normal layui-btn-small" style="line-height:20px">
                        <i class="layui-icon">&#xe615;</i>
                    </button>
                    <div class="toolbar-search-input">
                        <input type="text" id="keyWord" placeholder="字典名称或编码" autocomplete="off" class="layui-input" style="height:39px" />
                    </div>
                </div>
                <table id="gridList" class="layui-form layui-table elight-table" lay-skin="line">
                    <thead>
                        <tr>
                            <th>
                                <input type="checkbox" lay-skin="primary">
                            </th>
                            <th>编码</th>
                            <th>名称</th>
                            <th>排序码</th>
                            <th>状态</th>
                            <th>备注</th>
                        </tr>
                    </thead>
                    <!--内容容器-->
                    <tbody id="content"></tbody>
                </table>
                <div id="paged"></div>
            </div>
        </div>
    </div>
</body>
</html>

<!--内容模板-->
<script id="contentTpl" type="text/html">
      {{#  layui.each(d.list, function(index, item){ }}
    <tr>
        <td>
            <input type="checkbox" lay-skin="primary" value="{{item.Id}}"></td>
        <td>{{# if(item.EnCode==null){ }}
            {{# }else{ }}{{item.EnCode}}
            {{# } }}
        </td>
        <td>{{item.Name}}</td>
        <td>{{item.SortCode}}</td>
        <td>{{# if(item.IsEnabled==true){ }}  <span class="label label-success label-sm">启用</span>
            {{# }else{ }}  <span class="label label-dark label-sm">禁用</span>
            {{# } }}
        </td>
        <td>{{# if(item.Remark==null){ }}
            {{# }else{ }}{{item.Remark}}
            {{# } }}
        </td>
    </tr>
      {{#  }); }}
       {{# if(d.list.length<=0) { }}
          <tr style="color: red">
              <td colspan="6">查无数据。</td>
          </tr>
      {{# } }}
</script>

<script type="text/javascript">
    var paging;
    layui.config({
        base: parent._baseUrl
    }).use(['paging', 'form'], function() {
        var form = layui.form;
        paging = layui.paging();
        initGrid();
        $('#btnSearch').click(initGrid);
        $('#keyWord').bindEnterEvent(initGrid);
    });

    function initGrid() {
        paging.init({
            url: '/base/printTest/index',
            elem: '#content',
            tempElem: '#contentTpl',
            params: {
                keyWord: $("#keyWord").val()
            },
            pageConfig: {
                elem: 'paged',
                pageSize: 10,
            },
            success: function() {

            },
            fail: function(msg) {
                top.layer.msg(msg);
            }
        });
    }

    function btn_print() {
        var ids = $("#gridList").gridSelectedRowValue();
        if (ids.length < 1) {
            $.layerMsg("请勾选需要打印的数据。", "warning");
            return;
        }
        $.layerConfirm({
            content: "您已选中" + ids.length + "条数据, 确定打印吗？",
            callback: function() {
                $.formSubmit({
                    url: '/base/printTest/print',
                    data: { primaryKey: ids.join() },
                    success: function() {
                        $.layerMsg("打印成功");
                    }
                });
            }
        });
    }

    function btn_print_view() {
        var ids = $("#gridList").gridSelectedRowValue();
        if (ids.length < 1) {
            $.layerMsg("请勾选需要预览的数据。", "warning");
            return;
        }
        $.layerOpen({
            id: "printView",
            title: "打印预览",
            width: "720px",
            height: "470px",
            content: "/Content/PDFjs/web/viewer.html?file=/base/showpdf" + ids.join(),
            //content: "/base/printTest/printView?primaryKey=" + ids.join(),
            yes: function(iBody) {
                iBody.find('#btnSubmit').click();
                initGrid();
            }
        });
    };

    function btn_export() {
        var ids = $("#gridList").gridSelectedRowValue();
        if (ids.length < 1) {
            $.layerMsg("请勾选需要导出的数据。", "warning");
            return;
        }
        $.download({
            url: '/base/printTest/export',
            data: {
                primaryKey: ids.join(),
            }
        });
    };

    function btn_exportExcel() {
        $.download({
            url: '/base/printTest/exportExcel',
            data: {}
        });
    }
</script>

